IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'NewSiteID' AND TABLE_NAME = 'PreservationNoticeHistory')
BEGIN
	ALTER TABLE [dbo].[PreservationNoticeHistory] ADD [NewSiteID] uniqueidentifier NULL
END

IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'NewSiteUrl' AND TABLE_NAME = 'SendNoticeHistory')
BEGIN
	ALTER TABLE [dbo].[SendNoticeHistory] ADD [NewSiteUrl] nvarchar(1000) NULL
END

IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'NewSiteUrl' AND TABLE_NAME = 'SendNoticeQueue')
BEGIN
	ALTER TABLE [dbo].[SendNoticeQueue] ADD [NewSiteUrl] nvarchar(1000) NULL
END

IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'NewSiteID' AND TABLE_NAME = 'SendNoticeQueue')
BEGIN
	ALTER TABLE [dbo].[SendNoticeQueue] ADD [NewSiteID] uniqueidentifier NULL
END

IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'NewUrlValue' AND TABLE_NAME = 'UrlDictionary')
BEGIN
	ALTER TABLE [dbo].[UrlDictionary] ADD [NewUrlValue] nvarchar(1000) NULL
END

/* Indexes */
IF NOT EXISTS(SELECT 1 FROM sysindexes WHERE name = 'IDX_PreservationNoticeHistory_NewSiteID')
BEGIN
	CREATE NONCLUSTERED INDEX IDX_PreservationNoticeHistory_NewSiteID ON PreservationNoticeHistory (NewSiteID)
END
GO

IF NOT EXISTS(SELECT 1 FROM sysindexes WHERE name = 'IDX_PreservationNoticeHistory_NewSiteID_PreservationNoticeID')
BEGIN
	CREATE NONCLUSTERED INDEX IDX_PreservationNoticeHistory_NewSiteID_PreservationNoticeID ON PreservationNoticeHistory (NewSiteID, PreservationNoticeID)
END
GO

IF NOT EXISTS(SELECT 1 FROM sysindexes WHERE name = 'IDX_PreservationNoticeHistory_NewSiteID_PreservationNoticeID_CustodianID')
BEGIN
	CREATE NONCLUSTERED INDEX IDX_PreservationNoticeHistory_NewSiteID_PreservationNoticeID_CustodianID ON PreservationNoticeHistory (NewSiteID, PreservationNoticeID, CustodianID)
END
GO